package com.planegame.Obj;

import com.planegame.GameWin;
import com.planegame.utils.Gameutils;

import java.awt.*;

//boss
public class BossObj extends GameObject{
    int life=10;
    @Override
    public void setImg(Image img) {
        super.setImg(img);
    }

    @Override
    public void setX(int x) {
        super.setX(x);
    }

    @Override
    public void setY(int y) {
        super.setY(y);
    }

    @Override
    public void setWidth(int width) {
        super.setWidth(width);
    }

    @Override
    public void setHight(int hight) {
        super.setHight(hight);
    }

    @Override
    public void setSpeed(double speed) {
        super.setSpeed(speed);
    }

    @Override
    public void setFrame(GameWin frame) {
        super.setFrame(frame);
    }

    @Override
    public Image getImg() {
        return super.getImg();
    }

    @Override
    public int getX() {
        return super.getX();
    }

    @Override
    public int getY() {
        return super.getY();
    }

    @Override
    public int getWidth() {
        return super.getWidth();
    }

    @Override
    public int getHight() {
        return super.getHight();
    }

    @Override
    public double getSpeed() {
        return super.getSpeed();
    }

    public BossObj() {
        super();
    }

    public BossObj(Image img, int x, int y, double speed) {
        super(img, x, y, speed);
    }

    public BossObj(int x, int y, int width, int hight) {
        super(x, y, width, hight);
    }

    public BossObj(Image img, int x, int y, int width, int hight, double speed, GameWin frame) {
        super(img, x, y, width, hight, speed, frame);
    }

    @Override
    public void paintSelf(Graphics gImage) {
        super.paintSelf(gImage);
        if(x<-50||x>500) speed=-speed;
        x+=speed;
        //每次绘制之后判断是否与每一颗子弹碰撞
        for(ShellObj shellObj: Gameutils.shellObjList){
            if(this.getRec().intersects(shellObj.getRec())){
                //扣血
                this.life--;
                System.out.println("Boss被击中，还剩"+this.life+"滴血");
                shellObj.x=-200;shellObj.y=200;//移除
                Gameutils.removeList.add(shellObj);
                if(life==0) {
                    System.out.println("游戏胜利");
                    GameWin.state=2;
                }
            }
        }
        if (this.getRec().intersects(this.frame.planeObj.getRec())) {//注意这个this.frame，不是很懂
            GameWin.state=3;
        }
    }


    @Override
    public Rectangle getRec() {
        return super.getRec();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }
}

